package cn.ipenta.app.controller;

import cn.ipenta.app.controller.vo.CirculationVo;
import cn.ipenta.app.controller.vo.InoculationVo;
import cn.ipenta.app.service.VaccineService;
import cn.ipenta.core.ResultMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;
import java.util.Map;

/**
 * @author ipenta
 * @ClassName: VaccineTransactionController
 * @Description: TODO
 * @date 2017-09-21 下午4:18
 */
@Api(description = "疫苗流通/接种交易信息存储")
@Controller
@RequestMapping("/api/v1/tx/")
public class VaccineTransactionController {//vaccine-transaction-controller

	private Logger logger = Logger.getLogger(getClass());

	@Autowired
	VaccineService vaccineService;

	@ApiOperation(value = "存储接口：疫苗接种", notes = "用于存储疫苗【接种】信息", produces = "application/json")
	@PostMapping("inoculation")
	public @ResponseBody
	Map<String, Object> inoculation(@Valid @RequestBody InoculationVo inoculationVo) {

		return ResultMapper.success(vaccineService.recordInoculation(inoculationVo));
	}

	@ApiOperation(value = "存储接口：疫苗流通", notes = "用于存储疫苗【交易】信息", produces = "application/json")
	@PostMapping("circulation")
	public @ResponseBody
	Map<String, Object> circulation(@Valid @RequestBody CirculationVo circulationVo) {

		return ResultMapper.success(vaccineService.recordCirculation(circulationVo));
	}


}
